import React from 'react';

// 静态导入所有页面组件
const componentMap: Record<string, React.LazyExoticComponent<any>> = {
  // 首页
  'shouYe/index': React.lazy(() => import('../pages/home')),
  'shouYe': React.lazy(() => import('../pages/home')),
  
  // 登录页
  'Login/index': React.lazy(() => import('../pages/Login')),
  'Login': React.lazy(() => import('../pages/Login')),
  
  // 错误页
  'Error/404': React.lazy(() => import('../pages/Error/404')),
  'Error': React.lazy(() => import('../pages/Error/404')),
  
  // 设备相关
  'Device/index': React.lazy(() => import('../pages/Device')),
  'Device': React.lazy(() => import('../pages/Device')),
  'Device/Detail': React.lazy(() => import('../pages/Device/Detail')),
  
  // 店铺管理
  'shop/commodity': React.lazy(() => import('../pages/shop/commodity')),
  'shop/commodity/edit': React.lazy(() => import('../pages/shop/commodityEdit')),
  'shop/order': React.lazy(() => import('../pages/shop/order')),
  
  // 代理管理
  'agent/agent': React.lazy(() => import('../pages/agent/agent')),
  'agent': React.lazy(() => import('../pages/agent/agent')),
  
  // 个人中心
'personal/personal': React.lazy(() => import('../pages/personal/personal')),
'personal': React.lazy(() => import('../pages/personal/personal')),

// 超管个人中心
'platform/adminPersonal': React.lazy(() => import('../pages/platform/adminPersonal')),
'adminPersonal': React.lazy(() => import('../pages/platform/adminPersonal')),

// 数据经营
'data/data': React.lazy(() => import('../pages/data/data')),
'data': React.lazy(() => import('../pages/data/data')),

// 商家管理
'merchant/merchant': React.lazy(() => import('../pages/merchant/merchant')),
'merchant': React.lazy(() => import('../pages/merchant/merchant')),

// 入驻平台
'platform/platform': React.lazy(() => import('../pages/platform/platform')),
'platform': React.lazy(() => import('../pages/platform/platform')),

// 平台反馈
'feedback/feedback': React.lazy(() => import('../pages/feedback/feedback')),
'feedback': React.lazy(() => import('../pages/feedback/feedback')),

// 推广管理
'promotion/promotion': React.lazy(() => import('../pages/promotion/promotion')),
'promotion': React.lazy(() => import('../pages/promotion/promotion')),
  
  // 设备管理（保留原有映射）
  'shebei/shebei': React.lazy(() => import('../pages/shop/order')),
  'shebei': React.lazy(() => import('../pages/shop/order')),
  
  // 模块管理
  'mokuai/Mokuai': React.lazy(() => import('../pages/mokuai/Mokuai')),
  'mokuai': React.lazy(() => import('../pages/mokuai/Mokuai')),
  
  // 报表相关
  'biaoba/index': React.lazy(() => import('../pages/biaoba')),
  'biaoba': React.lazy(() => import('../pages/biaoba')),
  'biaoba/baojing': React.lazy(() => import('../pages/biaoba/baojing')),
  'biaoba/dengji': React.lazy(() => import('../pages/biaoba/dengji')),
  'biaoba/biaoba': React.lazy(() => import('../pages/biaoba/biaoba')),
};

// 动态加载组件
export const loadComponent = (component: string) => {
  const Component = componentMap[component];
  
  if (!Component) {
    console.warn(`Component not found: ${component}`);
    // 返回一个错误组件
    return React.lazy(() => import('../pages/Error/404'));
  }
  
  return Component;
};

export default componentMap; 